package co2.pojos;

import java.math.BigDecimal;
import java.util.Map;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@ViewScoped
public class LatNextBean {
	
	private String pesan1;
	private String title;
	private BigDecimal benar;
	private BigDecimal nilai;
	
	
	public LatNextBean(){
		Map map = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
		if(map!=null){
			String str = map.get("pesan1")!=null?map.get("pesan1").toString():"";
			String[] strs = str.split(";");
			 nilai = new BigDecimal(strs[0]);
			 benar = new BigDecimal(strs[1]);
			
			if(nilai.compareTo(new BigDecimal(80))>=0){
				title = "Congratulation!";
			}else if(nilai.compareTo(new BigDecimal(65))>=0 && nilai.compareTo(new BigDecimal(80))<0){
				title = "Nilaimu sudah mencukupi KKM, tingkatkan prestasimu ya?...  ";
			}else{
				title = "Nilaimu dibawah KKM,  belajar lebih giat ya?...";
			}
		}
	}


	public String getPesan1() {
		return pesan1;
	}


	public void setPesan1(String pesan1) {
		this.pesan1 = pesan1;
	}


	public synchronized String getTitle() {
		return title;
	}


	public synchronized void setTitle(String title) {
		this.title = title;
	}


	public synchronized BigDecimal getBenar() {
		return benar;
	}


	public synchronized void setBenar(BigDecimal benar) {
		this.benar = benar;
	}


	public synchronized BigDecimal getNilai() {
		return nilai;
	}


	public synchronized void setNilai(BigDecimal nilai) {
		this.nilai = nilai;
	}
}
